#!/bin/sh

# dwm-statuscmd 补丁对应 按钮命令

function toggleewwwindow(){
    window_name=$1
    # 判断是否运行eww如果有则打开eww的面板
    if [ -x "$( which eww )" ]; then
        # echo "[DEBUG] 打关eww面版"
        # eww --config ~/.config/eww daemon &
        # eww windows
        # eww --config ~/.config/eww open --toggle calendar-bottom-right-default
        # eww --config ~/.dwm/scripts/config/eww open --toggle eww controllcenter
        # eww --config ~/.dwm/scripts/config/eww open --toggle eww calendar
        eww_fonfig_dir="${HOME}/.dwm/scripts/config/eww"
        if [[ -d "$eww_fonfig_dir" ]]; then
            # eww --config "$eww_fonfig_dir" open --toggle  controlcenter
            # 关闭其他
            # eww --config ${HOME}/.dwm/scripts/config/eww close-all 
            # 打开
            eww --config "$eww_fonfig_dir" open --toggle  "$window_name"
        else
            notify-send $eww_fonfig_dir"位置没有eww配置文件，请安装。"
        fi
    else
        # 打开终端
        # echo "[DEBUG] 打开终端"
        notify-send "没有安装eww，请安装。"
        # /usr/local/bin/st -c float -g $(st_geometry center 100 30) &
    fi
}

# 外部参数输入赋值
statuscmd_number=$1
statuscmd_button=$2

# case "$statuscmd_number" in
#     1) notify-send "CPU usage" "$(ps axch -o cmd,%cpu --sort=-%cpu | head)" ;;
#     2) notify-send "CPU usage" "$(ps axch -o cmd,%cpu --sort=-%cpu | head)" ;;
#     3) st -e htop ;;
# esac

# case "$statuscmd_button" in
#     1) notify-send "CPU usage" "$(ps axch -o cmd,%cpu --sort=-%cpu | head)" ;;
#     2) notify-send "CPU usage" "$(ps axch -o cmd,%cpu --sort=-%cpu | head)" ;;
#     3) st -e htop ;;
# esac

statuscmd_number_button="$statuscmd_number-$statuscmd_button";
# case "$statuscmd_number_button" in
#     # 1-1) notify-send $statuscmd_number_button;;
#     1-1) notify-send $statuscmd_number_button;;
#     1-2) notify-send $statuscmd_number_button;;
#     1-3) notify-send $statuscmd_number_button;;
#     2-1) notify-send $statuscmd_number_button;;
#     2-2) notify-send $statuscmd_number_button;;
#     2-3) notify-send $statuscmd_number_button;;
#     3-1) notify-send $statuscmd_number_button;;
#     3-2) notify-send $statuscmd_number_button;;
#     3-3) notify-send $statuscmd_number_button;;
#     4-1) notify-send $statuscmd_number_button;;
#     4-2) notify-send $statuscmd_number_button;;
#     4-3) notify-send $statuscmd_number_button;;
#     5-1) notify-send $statuscmd_number_button;;
#     5-2) notify-send $statuscmd_number_button;;
#     5-3) notify-send $statuscmd_number_button;;
#     6-1) notify-send $statuscmd_number_button;;
#     6-2) notify-send $statuscmd_number_button;;
#     6-3) notify-send $statuscmd_number_button;;
#     7-1) notify-send $statuscmd_number_button;;
#     7-2) notify-send $statuscmd_number_button;;
#     7-3) notify-send $statuscmd_number_button;;
#     8-1) notify-send $statuscmd_number_button;;
#     8-2) notify-send $statuscmd_number_button;;
#     8-3) notify-send $statuscmd_number_button;;
#     9-1) notify-send $statuscmd_number_button;;
#     9-2) notify-send $statuscmd_number_button;;
#     9-3) notify-send $statuscmd_number_button;;
# esac


case "$statuscmd_number_button" in
    # 1-1) notify-send $statuscmd_number_button;;
    1-1) toggleewwwindow datetime;;
    1-2) notify-send $statuscmd_number_button;;
    # 1-3) notify-send $statuscmd_number_button;;
    1-3) toggleewwwindow calendar;;
    # 2-1) notify-send $statuscmd_number_button;;
    2-1) ${HOME}/.dwm/scripts/dmenu_menu.sh;;
    2-2) notify-send $statuscmd_number_button;;
    2-3) notify-send $statuscmd_number_button;;
    # 3-1) notify-send $statuscmd_number_button;;
    3-1) toggleewwwindow volume;;
    3-2) notify-send $statuscmd_number_button;;
    3-3) notify-send $statuscmd_number_button;;
    # 4-1) notify-send $statuscmd_number_button;;
    4-1) toggleewwwindow disk;;
    4-2) notify-send $statuscmd_number_button;;
    4-3) notify-send $statuscmd_number_button;;
    # 5-1) notify-send $statuscmd_number_button;;
    # 5-1) ${HOME}/.dwm/scripts/app-starter.sh controllpanel;;
    5-1) toggleewwwindow controllpanel;;
    5-2) notify-send $statuscmd_number_button;;
    # 5-3) notify-send $statuscmd_number_button;;
    5-3) toggleewwwindow controlcenter ;;
    # 6-1) notify-send $statuscmd_number_button;;
    6-1) toggleewwwindow bluetooth;;
    6-2) notify-send $statuscmd_number_button;;
    6-3) notify-send $statuscmd_number_button;;
    # 7-1) notify-send $statuscmd_number_button;;
    7-1) toggleewwwindow brightness;;
    7-2) notify-send $statuscmd_number_button;;
    7-3) notify-send $statuscmd_number_button;;
    8-1) notify-send $statuscmd_number_button;;
    8-2) notify-send $statuscmd_number_button;;
    8-3) notify-send $statuscmd_number_button;;
    9-1) notify-send $statuscmd_number_button;;
    9-2) notify-send $statuscmd_number_button;;
    9-3) notify-send $statuscmd_number_button;;
    # 10-1) notify-send $statuscmd_number_button;;
    # 10-2) notify-send $statuscmd_number_button;;
    # 10-3) notify-send $statuscmd_number_button;;
    # 11-1) notify-send $statuscmd_number_button;;
    # 11-2) notify-send $statuscmd_number_button;;
    # 11-3) notify-send $statuscmd_number_button;;
    # 12-1) notify-send $statuscmd_number_button;;
    # 12-2) notify-send $statuscmd_number_button;;
    # 12-3) notify-send $statuscmd_number_button;;
    # 13-1) notify-send $statuscmd_number_button;;
    # 13-2) notify-send $statuscmd_number_button;;
    # 13-3) notify-send $statuscmd_number_button;;
    # 14-1) notify-send $statuscmd_number_button;;
    # 14-2) notify-send $statuscmd_number_button;;
    # 14-3) notify-send $statuscmd_number_button;;
    # 15-1) notify-send $statuscmd_number_button;;
    # 15-2) notify-send $statuscmd_number_button;;
    # 15-3) notify-send $statuscmd_number_button;;
    # 16-1) notify-send $statuscmd_number_button;;
    # 16-2) notify-send $statuscmd_number_button;;
    # 16-3) notify-send $statuscmd_number_button;;
    # 17-1) notify-send $statuscmd_number_button;;
    # 17-2) notify-send $statuscmd_number_button;;
    # 17-3) notify-send $statuscmd_number_button;;
    # 18-1) notify-send $statuscmd_number_button;;
    # 18-2) notify-send $statuscmd_number_button;;
    # 18-3) notify-send $statuscmd_number_button;;
    # 19-1) notify-send $statuscmd_number_button;;
    # 19-2) notify-send $statuscmd_number_button;;
    # 19-3) notify-send $statuscmd_number_button;;
    # 20-1) notify-send $statuscmd_number_button;;
    # 20-2) notify-send $statuscmd_number_button;;
    # 20-3) notify-send $statuscmd_number_button;;
esac

